﻿using System;

namespace VioletDevelopmentLaboratory.Net.Web.Component
{
	public abstract class BoardListPartBase : BoardTemplateBase
	{
		public virtual void AccessValidate()
		{
			Board CurrentBoard = (Board)this.Page.Items["CurrentBoard"];
			VBoardUserInfo CurrentUserInfo = (VBoardUserInfo)this.Page.Items["CurrentUserInfo"];

			//목록보기 권한이 있는지 검사
			if (!(CurrentUserInfo.IsAdministrator ||
				CurrentUserInfo.IsSysop(CurrentBoard) ||
				CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.ListView)))
			{
				//목록보기 권한 없음
				VUtility.GoToMessagePage(Page, VUtility.GetVWebGlobalResource("Board_Do_ThreadList_Rejection"), ResolveUrl("~/"), true, 3);
			}
		}

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			AccessValidate();
		}
	}
}
